#include "SRGene.h"

SRGene::SRGene(Box * pBox) : Gene(pBox)
{
	this->m_pBox=pBox;
}

SRGene::~SRGene(void)
{
}

void SRGene::makeExpressionTree()
{
	string gen = this->getWhole();
	//int i=0;
	SRExpressionNode* nRoot;
	
	if(this->m_pBox->isFunction(gen[0])){
		this->m_pETRoot =  new SROperNode(this->m_pBox,gen[0]);
	}
	else{
		this->m_pETRoot = new SRVarNode(this->m_pBox,gen[0]);
		//return this->m_pBox->charValue(gen[0]);
	}


	//while(i<this->m_pBox->geneLength){
	for (int i=1;i<this->m_pBox->geneLength;i++){
		
		this->m_pETRoot->addNode(&gen[i]);
		//nRoot->print();
		//std::cout<<std::endl;
	}
}
